class Step < ActiveRecord::Base
  
    include ModelHelpers
    
    belongs_to :link
    belongs_to :path
    
    validates_presence_of :path_id, :link_id, :title, :sequence
    
    ###############################################
    # virtual attribute for the uri.
    def uri
        if self.link
            return self.link.uri
        elsif @uri_value
            return @uri_value
        else
            return nil
        end
    end

    def uri=(new_uri)
        @uri_errors = Array.new
        link = Link.find_or_create_by_uri(new_uri)
        if !process_errors(link, @uri_errors)
            self.link = link 
        end
    end
    
end